import request from '@/utils/request'

// 获取任务列表
export function getCrawlerList(params) {
    return request({
        url: '/crawler/api/v1/tasks',
        method: 'get',
        params
    })
}

// 创建任务
export function createCrawlerTask(taskData) {
    return request({
        url: '/crawler/api/v1/tasks',
        method: 'post',
        data: taskData
    })
}

// 获取任务详情
export function getCrawlerTaskDetail(taskId) {
    return request({
        url: `/crawler/api/v1/tasks/${taskId}`,
        method: 'get'
    })
}

// 获取文章列表
export function getArticleList(params) {
    return request({
        url: '/crawler/api/v1/articles',
        method: 'get',
        params
    })
}

// 获取文章详情
export function getArticleDetail(id) {
    return request({
        url: `/crawler/api/v1/articles/${id}`,
        method: 'get'
    })
}

// 删除文章
export function deleteArticle(id) {
    return request({
        url: `/crawler/api/v1/articles/delete/${id}`,
        method: 'delete'
    })
}

// 删除任务
export function deleteTask(id) {
    return request({
        url: `/crawler/api/v1/tasks/${id}`,
        method: 'delete'
    })
}

// 批量删除文章
export function batchDelete(ids) {
    return request({
        url: '/crawler/api/v1/articles/batch-delete',
        method: 'delete',
        data: { ids }
    })
}

// 批量删除任务
export function batchDeleteTask(ids) {
    return request({
        url: '/crawler/api/v1/tasks/batch-delete',
        method: 'delete',
        data: { ids }
    })
}

// 获取统计数据
export function getStatistics() {
    return request({
        url: '/crawler/api/v1/statistics',
        method: 'get'
    })
}
